package com.lcf.system.controller;


import com.lcf.system.dto.GoodsCartDTO;
import com.lcf.system.service.GoodsCartService;
import com.lcf.system.vo.GoodsCartVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 购物车(GoodsCart)表控制层
 *
 * @author lcf
 * @since 2025-04-24 21:14:33
 */
@Tag(name = "购物车")
@RestController
@RequestMapping("goodsCart")
public class GoodsCartController {
    @Resource
    private GoodsCartService goodsCartService;

    /**
     * 新增
     */
    @Operation(summary = "新建")
    @PostMapping
    public boolean insert(@RequestBody @Validated GoodsCartDTO dto) {
        return goodsCartService.insert(dto);
    }

    /**
     * 编辑
     */
    @Operation(summary = "修改")
    @PostMapping("{id}")
    public boolean update(@PathVariable @Schema(description = "购物车id") long id,
                   @RequestBody @Validated GoodsCartDTO dto) {
        return goodsCartService.update(id, dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除")
    @DeleteMapping("{id}")
    public boolean delete(@PathVariable @Schema(description = "购物车id") long id) {
        return goodsCartService.delete(id);
    }

    /**
     * 查询
     */
    @Operation(summary = "查询")
    @GetMapping("{id}")
    public GoodsCartVO query(@PathVariable @Schema(description = "购物车id") long id) {
        return goodsCartService.query(id);
    }

    /**
     * 列表
     */
    @Operation(summary = "列表")
    @GetMapping("list")
    public List<GoodsCartVO> myList() {
        return goodsCartService.myList();
    }
}

